#include "worker.h"
#include "ui_worker.h"
#include "dbmanager.h"
#include "entity/workerentity.h"

Worker::Worker(QWidget *parent) :
    QWidget(parent), ui(new Ui::Worker)
{
    ui->setupUi(this);
    connect(ui->okButton, SIGNAL(clicked()), this, SLOT(okClicked()));
    connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clearClicked()));
}

Worker::~Worker()
{
    delete ui;
}

void Worker::okClicked()
{
    WorkerEntity * worker = new WorkerEntity();
    worker->setName(ui->nameText->text());
    worker->setAddress(ui->addrText->text());
    worker->setCity(ui->cityText->text());
    worker->setNicNo(ui->nicNoText->text());
    worker->setPhone(ui->phoneText->text());
    worker->setJoinedDate(ui->joinDateText->text());
    worker->setDeleted(0);

    DBManager * dbm = DBManager::getGlobal();
    dbm->insertWorker(worker);

    delete worker;
}

void Worker::clearClicked()
{

}


